using System;
using System.Collections;

namespace Sedna.Core.Controller.Configurations
{
	/// <summary>
	/// Summary description for RegularExpressionValidatorI18nConfiguration.
	/// </summary>
	public class RegularExpressionValidatorI18nConfiguration : RegularExpressionValidatorConfiguration
	{
		private IDictionary i18nExpressionMap = new Hashtable();

		public IDictionary I18nExpressionMap
		{
			get { return i18nExpressionMap;}
			set { i18nExpressionMap = value;}
		}

		public override string ValidationExpression
		{
			get
			{
				if (i18nExpressionMap[PrincipalWrapper.Culture.Name] != null)
				{
					return (String)i18nExpressionMap[PrincipalWrapper.Culture.Name];
				}

				if (!PrincipalWrapper.Culture.IsNeutralCulture && i18nExpressionMap[PrincipalWrapper.Culture.Parent.Name] != null)
				{
					return (String)i18nExpressionMap[PrincipalWrapper.Culture.Parent.Name];
				}

				return base.ValidationExpression;
			}
			/* Default expression for invariant culture */
			set
			{
				base.ValidationExpression = value;
			}
		}
	}
}
